<script setup>
import { ref } from 'vue'
import { Notebook, SuitcaseLine, Monitor } from '@element-plus/icons-vue'

const isExpand = ref(true)

const nav = [{
    label: '客户管理',
    link: '/crm',
    icon: Notebook
},{
    label: '任务/审批',
    link: '/task',
    icon: SuitcaseLine
},{
    label: '日志',
    link: '/log',
    icon: Monitor
}]
</script>
<template>
    <header>
        <div class="logo">
            <img src="../assets/img/logo_black.png" alt="">
        </div>
        <nav>
            <ul>
                <li v-for="item in nav" :key="item.link">
                    <router-link :to="item.link">
                        <el-icon><component :is="item.icon"/></el-icon>
                        <span>{{ item.label }}</span>
                    </router-link>
                </li>
            </ul>
            <a></a>
        </nav>
        <div class="opration"></div>
    </header>
    <div>
        <aside :class="{expand: isExpand}">
            <div>
                <slot></slot>
            </div>
            <a @click="isExpand = !isExpand">=</a>
        </aside>
        <main>
            <router-view></router-view>
        </main>
    </div>
</template>
<style scoped lang="scss">
    header{
        height: 60px;
        display: flex;
        padding: 0 30px;
        background: #fff;
        box-shadow: 0 1px 2px #dbdbdb;
        .logo{
            width: 150px;
            padding-top: 10px;
            margin-right: 20px;
            img{
                width: 100%;
                vertical-align: middle;
            }
        }
        nav, ul{
            display: flex;
        }
        nav{
            a{
                display: block;
                height: 100%;
                font-weight: 500;
                color: #2a304d;
                box-sizing: border-box;
                border-bottom: 3px solid transparent;
                &.router-link-active{
                    color: #2362fb;
                    border-bottom-color: #2362fb;
                }
                &:hover{
                    color: #2362fb;
                }
            }
            i, span{
                vertical-align: middle;
            }
            i{
                margin-right: 5px;
            }
        }
        li{
            line-height: 60px;
            font-size: 16px;
            font-weight: 500;
            color: #2a304d;
            margin: 0 20px;
        }
        &+div{
            height: calc(100vh - 60px);
            display: flex;
        }
    }
    aside{
        width: 60px;
        color: rgb(190, 190, 192);
        background: #001529;
        transition: width .3s;
        display: flex;
        flex-direction: column;
        div{
            flex: 1;
            overflow: auto;
        }
        a{
            text-align: right;
            padding: 5px 10px;
            background: darkolivegreen;
            cursor: pointer;
        }
        &.expand{
            width: 200px;
        }
    }
    main{
        flex: 1;
        min-width: 1200px;
        overflow: auto;
        position: relative;
    }
</style>
